package com.itmuch.cloud.movieservice.controller;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.itmuch.cloud.movieservice.entity.User;
import com.itmuch.cloud.movieservice.repository.UserRepository;

@RestController
public class UserController {
	
	@Autowired
	private UserRepository userRepository;
	
	@GetMapping("/findUserByid/{id}")
	public User findUserByid(@PathVariable Long id) {
		Optional<User> optional = userRepository.findById(id);
		User user =optional.get();
		return user;
	}
	
	@GetMapping("/findAll")
	public List<User> findAll() {
		return userRepository.findAll();
	}
}
